/**
 * 类元数据管理器
 */
import {BusMap, Key, MetadataValue} from "./common";


/**
 * 领域 (注解所属的大的分类) 的元数据
 */
export class ClassMetadata {

	public readonly affiliatedMetadataDomain: Key;
	/**
	 * 所注解的类
	 */
	public readonly annotatedClass: Key;

	public readonly metadataKey: Key;
	public readonly metadataValue: MetadataValue;

	constructor(affiliatedMetadataDomain: Key, annotatedClass: Key, metadataKey: Key, metadataValue: MetadataValue) {
		this.affiliatedMetadataDomain = affiliatedMetadataDomain;
		this.annotatedClass = annotatedClass;
		this.metadataKey = metadataKey;
		this.metadataValue = metadataValue;
	}

}

export class ClassMetadataManager {
	/**
	 * [Key, Key] => [annotatedClass, metadataKey]
	 * @private
	 */
	public readonly domainMetadataList: BusMap<[Key, Key, Key], ClassMetadata>;

	constructor() {
		this.domainMetadataList = new BusMap<[Key, Key, Key], ClassMetadata>();
	}

	public add(affiliatedMetadataDomain: Key, annotatedClass: Key, metadataKey: Key, metadataValue: MetadataValue): void {
		this.domainMetadataList.set(
			[affiliatedMetadataDomain, annotatedClass, metadataKey],
			new ClassMetadata(affiliatedMetadataDomain, annotatedClass, metadataKey, metadataValue)
		);
	}
}

